import VuiElement from '../../base/element';
import VuiSvgContainer from '../../components/icon/svg-container';
import VuiText from '../../components/text';

export default class SelectorTextItem extends VuiElement {
  constructor(itemName, action) {
    super();
    this._className = {
      container: 'vui-selection-item',
      remove: 'vui-selection-item-remove'
    };
    this.itemName = itemName;
    this._actions = {
      action
    };
  }

  init() {
    const cls = this._className;
    const actions = this._actions;
    this.initContainer();
    const title = VuiText.newInstance(this.itemName);
    const removeBtn = VuiSvgContainer.newInstance('close', cls.remove);
    removeBtn.setClickListener(actions.action);
    this.append([title, removeBtn]);
    return this;
  }
}
